import $http from "@/ajax/http.js";

export const shopmsg = {
	data() {
		return {
			shop: [],
			storepackage: [],
			roles:wx.getStorageSync("roles")
		}
	},
	onLoad() {
		this.getStoreInfoList();
	},
	methods: {
		getStoreInfoList(){
			if(this.roles == 5){
				this.shopmsgBusiness();
			}else if(this.roles == 7){
				this.shopmsgServer();
			}else if(this.roles == 4){
				this.shopmsgCity();
			}else if(this.roles == 3){
				this.shopmsgCause();
			}
		},
		
		shopmsgBusiness() {
			$http.request({
				url: "/bus/index/getStoreInfoList",
				method: 'GET'
			}).then((res) => {
				console.log(res, '首页数据');
				this.shop = res;
				this.storepackage = res.map(item => {
					return item.packageMap;
				});
				
				console.log(this.storepackage,"this.storepackage");
			})
		},
		
		shopmsgServer(){
			$http.request({
				url: "/waiter/index/getStoreInfoList",
				method: 'GET'
			}).then((res) => {
				console.log(res, '首页数据');
				this.shop = res;
				this.storepackage = res.map(item => {
					return item.packageMap;
				});
				
				console.log(this.storepackage,"this.storepackage");
			})
		},
		// 城市合伙人
		shopmsgCity(){
			$http.request({
				url: "/city/index/getStoreInfoList",
				method: 'GET'
			}).then((res) => {
				console.log(res, '首页数据');
				this.shop = res;
				this.storepackage = res.map(item => {
					return item.packageMap;
				});
				
				console.log(this.storepackage,"this.storepackage");
			})
		},
		
		// 事业合伙人
		shopmsgCause(){
			$http.request({
				url: "/work/index/getStoreInfoList",
				method: 'GET'
			}).then((res) => {
				console.log(res, '首页数据');
				this.shop = res;
				this.storepackage = res.map(item => {
					return item.packageMap;
				});
				console.log(this.storepackage,"this.storepackage");
			})
		}
	}
}